package com.ruoyi.wms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.wms.domain.WmsLastDate;
import com.ruoyi.wms.service.IWmsLastDateService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 最近一次结账日期Controller
 * 
 * @author ruoyi
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/wms/lastDate")
public class WmsLastDateController extends BaseController
{
    @Autowired
    private IWmsLastDateService wmsLastDateService;

    /**
     * 查询最近一次结账日期列表
     */
    @PreAuthorize(hasPermi = "wms:lastDate:list")
    @GetMapping("/list")
    public TableDataInfo list(WmsLastDate wmsLastDate)
    {
        startPage();
        List<WmsLastDate> list = wmsLastDateService.selectWmsLastDateList(wmsLastDate);
        return getDataTable(list);
    }

    /**
     * 导出最近一次结账日期列表
     */
    @PreAuthorize(hasPermi = "wms:lastDate:export")
    @Log(title = "最近一次结账日期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsLastDate wmsLastDate) throws IOException
    {
        List<WmsLastDate> list = wmsLastDateService.selectWmsLastDateList(wmsLastDate);
        ExcelUtil<WmsLastDate> util = new ExcelUtil<WmsLastDate>(WmsLastDate.class);
        util.exportExcel(response, list, "最近一次结账日期数据");
    }

    /**
     * 获取最近一次结账日期详细信息
     */
    @PreAuthorize(hasPermi = "wms:lastDate:query")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") String uuid)
    {
        return AjaxResult.success(wmsLastDateService.selectWmsLastDateByUuid(uuid));
    }

    /**
     * 新增最近一次结账日期
     */
    @PreAuthorize(hasPermi = "wms:lastDate:add")
    @Log(title = "最近一次结账日期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsLastDate wmsLastDate)
    {
        return toAjax(wmsLastDateService.insertWmsLastDate(wmsLastDate));
    }

    /**
     * 修改最近一次结账日期
     */
    @PreAuthorize(hasPermi = "wms:lastDate:edit")
    @Log(title = "最近一次结账日期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsLastDate wmsLastDate)
    {
        return toAjax(wmsLastDateService.updateWmsLastDate(wmsLastDate));
    }

    /**
     * 删除最近一次结账日期
     */
    @PreAuthorize(hasPermi = "wms:lastDate:remove")
    @Log(title = "最近一次结账日期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable String[] uuids)
    {
        return toAjax(wmsLastDateService.deleteWmsLastDateByUuids(uuids));
    }
}
